/* 初始化推荐 */
axios({
    method: "GET",
    url: "http://127.0.0.1:8400/get",
}).then(response => {
    $.each(response.data, function(index, item) {
        $("#ul").append(` <li search_product_type="global_deal" search_show_id="0" search_product_id="5002978" search_category_id="14" search_brand_id="25320" search_hash_id="ht20191120135354p5002978" search_warehouse_id="19" price="24">
            <a href="javascript:alert('不给点，此功能没写')">
                <div class="pic"><img src="${item.img}"></div>
                <div class="side_item">${item.span}</div>
                <p class="pic_price"><strong><span class="currency_arial">¥</span>${item.money}</strong>(<span class="pic_price_mak">¥${item.mon}</span>)</p><input type="hidden" value="ht20191120135354p5002978"></a>
        </li> `)
    })
})

/* 向你推荐 往右 */
let index = 0;

function right() {
    index++;
    if (index >= 2) {
        return false;
    }
    let ul = $("#ul");
    let imgwidth = 170 * 6
    var width = index * imgwidth;

    $("#ul").css("transform", "translate(-" + width + "px,0)");
}
/* 向你推荐 往左 */
function left() {
    index--;
    if (index < 0) {
        return false;
    }
    let ul = $("#ul");
    let imgwidth = 170 * 6
    var width = index * imgwidth;
    $("#ul").css("transform", "translate(-" + width + "px,0)");
}
/* 常见问题点击查看 */
let i = 0;
$("#btn").click(function() {

    if (i == 0) {
        $("#btn").html("点击收起-");

        $("#jmcjwt_img").css("display", "block");
        i = 1;
    } else {
        $("#btn").html("点击查看+");

        $("#jmcjwt_img").css("display", "none");
        i = 0;
    }
})


/* 加入购物车 */

let a = 0;
$(".deal_sku_input").click(function() {
    if (a == 0) {
        $("#sku_select").css("display", "block");
        a = 1;
    } else {
        $("#sku_select").css("display", "none");
        a = 0;
    }
})
$("#sku_select>li>a").click(function() {
    $(".deal_sku_input").html($(this).find("span").html());
})

function fun() {
    $("html,body").animate({ scrollTop: $(".abc").offset().top }, 100);
}

function fun1() {
    $("html,body").animate({ scrollTop: $(".abcd").offset().top }, 100);
}

function fun2() {
    $("html,body").animate({ scrollTop: $(".yhkb").offset().top }, 100);
}